package com.hopedove.utils;

import com.hopedove.data.Datetime;

import java.time.LocalDateTime;

public class DateTimeUtil {

    /**
     * 为特殊班次调整时间
     */
    public static Datetime adjustForSpecialShift(Datetime origin) {
        final int hour = origin.hoursOfDay();
        final int minute = origin.minute();
        if (hour < 7 || (hour == 7 && minute < 30)) {
            LocalDateTime ldt = origin.getLocalDateTime();
            LocalDateTime yesterday = ldt.minusDays(1);
            return new Datetime(yesterday);
        }
        return origin;
    }


}
